package com.longxi.tianjintianbao.ui.adapter.multitype.houseinspection;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.listener.AdapterListener;
import com.longxi.tianjintianbao.model.houseinspection.HouseAssets;
import com.longxi.tianjintianbao.model.houseinspection.HouseCompensate;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by cxw on 2018/2/20.
 */
public class HouseCompensateBinder extends ItemViewBinder<HouseCompensate, HouseCompensateBinder.ViewHolder> {

    private AdapterListener listener;
    private String[] state = {"未检验","正常","破损","赔偿","未恢复"};

    public HouseCompensateBinder(AdapterListener listener) {
        this.listener = listener;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_house_assets, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull HouseCompensate houseCompensate) {
        holder.mTvName.setText("资产名称: " + houseCompensate.getName());
        holder.mTvType.setText("资产类别: " + houseCompensate.getType());
        holder.mTvNumber.setText("资产编号: " + houseCompensate.getCode());
        holder.mTvState.setText(houseCompensate.getRepairmode()  + " " + houseCompensate.getRecoverystate());
        holder.mRlBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClick(holder.getAdapterPosition());
            }
        });
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        RelativeLayout mRlBtn;
        TextView mTvName;
        TextView mTvState;
        TextView mTvType;
        TextView mTvNumber;
        ViewHolder(View itemView) {
            super(itemView);
            mRlBtn = itemView.findViewById(R.id.rlBtn);
            mTvName = itemView.findViewById(R.id.tvName);
            mTvState = itemView.findViewById(R.id.tvState);
            mTvType = itemView.findViewById(R.id.tvType);
            mTvNumber = itemView.findViewById(R.id.tvNumber);
        }
    }
}
